#include <my_header.h>
/* Usage: ./07_完全无关版ls指令  pathname*/
int main(int argc,char *argv[])
{   
    //判断输入的指令数
    ARGS_CHECK(argc,2);
    //打开目录流
    DIR * dirp = opendir(argv[1]);
    //错误处理判断
    ERROR_CHECK(dirp, NULL, "opendir");
    //创建一个指针用来指向目录流结构体
    //用来读取结构体的内容
    struct  dirent *pdirent;
    //while循环读取并打印目录信息，循环结束的条件是返回值为NULL
    while((pdirent = readdir(dirp)) != NULL){
        printf("inode Num = %lu"
               "reclen = %hu"
               "type = %u"
               "name = %s\n",
               pdirent->d_ino,
               pdirent->d_reclen,
               pdirent->d_type,
               pdirent->d_name
               );
    }
    //打印完成及时关闭目录流
    closedir(dirp);

    return 0;
}

